package com.ourteam.product.api;

import org.apache.commons.lang.StringUtils;

import com.ourteam.frame.web.AbstractSearchModel;
import com.ourteam.product.ui.dao.ProductUIPageDAOQueryBean;
import com.ourteam.product.ui.domain.ProductUIPageBean;

public class ProductUIPageSearchModel extends AbstractSearchModel<ProductUIPageDAOQueryBean> {

	private Long domainId;

	private String pageCode;

	public String getPageCode() {
		return pageCode;
	}

	public void setPageCode(String pageCode) {
		this.pageCode = pageCode;
	}

	public Long getDomainId() {
		return domainId;
	}

	public void setDomainId(Long domainId) {
		this.domainId = domainId;
	}

	@Override
	public String getMappedDAOField(String aProperty) {
		return ProductUIPageBean.getMappedDAOField(aProperty);
	}

	@Override
	protected void doBuildQueryBean(ProductUIPageDAOQueryBean queryBean) throws Exception {
		ProductUIPageDAOQueryBean.Criteria criteria = queryBean.createCriteria();
		if (domainId != null && domainId != 0) {
			criteria.andDomainIdEqualTo(domainId);
		}

		if (StringUtils.isNotBlank(pageCode)) {
			criteria.andPageCodeLike(pageCode);
		}
	}

}
